package com.ruoyi.web.controller.Alipay;

import com.ruoyi.system.domain.alipay.AliPayVO;
import com.ruoyi.system.service.alipayservice.AlipayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/alipay")
public class ApiAlipayServiceController {
    private static final Logger logger = LoggerFactory.getLogger(ApiAlipayServiceController.class);
    @Autowired
    private AlipayService alipayService;

    /**
     * @Description: 订单支付宝支付回调
     */

    @RequestMapping(value = "/aliPayCallBack", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, String> aliPayOrderCallBack(HttpServletRequest request){
        Map<String, String> map = new HashMap<String, String>();
        try {
            AliPayVO aliPayVo = alipayService.aliPayCallBack(request);
            alipayService.aliPayOrderCallBack(aliPayVo);
            map.put("msg", "SUCCESS");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("aliPayOrderCallBack Error.",e);
        }
        return map;
    }




}
